	  mui.init();
		// 实例化vue对象（MVVM中的View Model）
    var app = new Vue({
      el: '#app',
      data: {
          id:"",
          businessCount:"",
          numberOfVote:0,
          sumVote:0,
          businessList:"",
          business:"",
          business_image:"",
   
          
      },

        created: function () {
            var url = "http://59.110.165.13:7500/business/findAllBusiness";
                axios.post(url,{px:"0"}).then(function(res) {
                	
                    app.businessList = res.data.result.list;
                    console.log(app.businessList)
                    app.sumVote = res.data.result.sumVote;
                    app.businessCount = res.data.result.businessCount;
                   // app.business_image=res.data.result.list[0].picList;
                 
                });
                /*tab页面切换*/
                (function($) {
				$('.mui-scroll-wrapper').scroll({
					indicators: true //是否显示滚动条
				});
				      
				var html3 = '<ul class="mui-table-view"><li class="mui-table-view-cell">第三个选项卡子项-1</li><li class="mui-table-view-cell">第三个选项卡子项-2</li><li class="mui-table-view-cell">第三个选项卡子项-3</li><li class="mui-table-view-cell">第三个选项卡子项-4</li><li class="mui-table-view-cell">第三个选项卡子项-5</li></ul>';
				var item2 = document.getElementById('item2mobile');
				var item3 = document.getElementById('item3mobile');
				var item1 = document.getElementById('item1mobile');

				document.getElementById('sliderlist').addEventListener('slide', function(e) {
					if (e.detail.slideNumber === 1) {
				       app.selectVoteList("2");
						
					} else if (e.detail.slideNumber === 2) {
						app.selectVoteList("1");
					}
					else if (e.detail.slideNumber === 0) {
						app.selectVoteList("0");
											
					}
				});
				
				var sliderSegmentedControl = document.getElementById('sliderSegmentedControl');
				$('.mui-input-group').on('change', 'input', function() {
					if (this.checked) {
						sliderSegmentedControl.className = 'mui-slider-indicator mui-segmented-control mui-segmented-control-inverted mui-segmented-control-' + this.value;
						//force repaint
						sliderProgressBar.setAttribute('style', sliderProgressBar.getAttribute('style'));
					}
				});
			})(mui);
                
        },
         methods:{
                
                selectVoteList:function(px){   
                	console.log("-----------");
                 var url = "http://59.110.165.13:7500/business/findAllBusiness";
                   	axios.post(url,{px:px}).then(function(res) {
                		console.log(res);
                     app.businessList = res.data.result.list;
                     app.sumVote = res.data.result.sumVote;
                     app.businessCount = res.data.result.businessCount;
                     app2.businessList = res.data.result.list;
                     app2.sumVote = res.data.result.sumVote;
                     app2.businessCount = res.data.result.businessCount;
                     app3.businessList = res.data.result.list;
                     app3.sumVote = res.data.result.sumVote;
                     app3.businessCount = res.data.result.businessCount;
             
                });   
                } ,
                
                addvote:function(index){
                    this.sumVote=this.sumVote++;
                   // this.selected = index; // 修改的位置
                    app.business = this.businessList[index];
                    console.log("business"+app.business);
             
//                  console("投票人"+name "----商户ID"+id);
                   var url = "http://59.110.165.13:7500/business/businessVote";
                   axios.post(url,{id:app.business.id,name:app.business.business_name}).then(function(res) {
                	console.log(res);
                    appVote.sumVote= res.data.result.sumVote;
                    	mui.alert('', '投票成功！')
                }); 
                },
                
								detail:function(index){       
									app.business = this.businessList[index];
									app.id = app.business.id;                  
									window.location.href='business_detail.html?id='+app.id;      
                         
                }
            }
    })           		
		
	 // 实例化vue对象（MVVM中的View Model）
	 /*统计*/
    var appVote = new Vue({
      el: '#appVote',
      data: {
          businessCount:"",
          numberOfVote:0,
          sumVote:0,
          businessList:"",
                   
      },

        created: function () {
            var url = "http://59.110.165.13:7500/business/findAllBusiness";
                axios.post(url,{px:"0"}).then(function(res) {
                  //  appVote.businessList = res.data.result.list;
                    appVote.sumVote = res.data.result.sumVote;
                    appVote.businessCount = res.data.result.businessCount;
                });
        },
         methods:{
                
            }
    })
      
			
//		document.getElementById("alertBtn").addEventListener('tap', function() {
//				mui.alert('感谢您的支持', '投票成功！', function() {
////					info.innerText = '你刚关闭了警告框';
//					app.addvote(1);
//				});
//			});
			
	/*加载最新排行*/
	var app2 = new Vue({
      el: '#app2',
      data: {
           businessCount:"",
          numberOfVote:0,
          sumVote:0,
           businessList:"",
          
      },

         methods:{
            }
    })
    
    /*加载人气排行*/
		var app3 = new Vue({
      el: '#app3',
      data: {
          businessCount:"",
          numberOfVote:0,
          sumVote:0,
          businessList:"",
          },

         methods:{
            }
    })
		

    /*加载排行榜*/
		var appPaihangbang = new Vue({
      el: '#appPaihangbang',
      data: {
			  businessCount:"",
			  numberOfVote:0,
			  sumVote:0,
			  businessList:"",
			},
      created: function () {
      	console.log("加载排行榜");
            var url = "http://59.110.165.13:7500/business/findAllBusiness";
                axios.post(url,{px:"1"}).then(function(res) {
                	 console.log("进入投票排行页面"+res.data.result.list);
                     appPaihangbang.businessList = res.data.result.list;
                     appPaihangbang.sumVote = res.data.result.sumVote;
                     appPaihangbang.businessCount = res.data.result.businessCount;
                });
        },
			methods:{
				         
				detail:function(index){       
							appPaihangbang.business = this.businessList[index];
							appPaihangbang.id = appPaihangbang.business.id;                  
							window.location.href='business_detail.html?id='+appPaihangbang.id;      
                 
        }
			}
   })		
		
      
   // 节流函数
	const delay = (function() {
		console.log("节流函数");
	  let timer = 0;
	  return function(callback, ms) {
	    clearTimeout(timer);
	    timer = setTimeout(callback, ms);
	  };
	})();
 
      
		
    /*搜索 */
		var appsearch = new Vue({
      el: '#appsearch',
      data: {
        searchModel: "",
			  businessList:"",
			  
			},
			watch: {
	  //watch title change
	    title() {
	      delay(() => {
	        this.searchData();
	      }, 300);
	    },
    },
//    created: function () {
//
//    	 console.log("开始搜索");
//          var url = "http://59.110.165.13:7500/business/findAllBusiness";
//              axios.post(url,{px:"1"}).then(function(res) {    
//              		 console.log("进入搜索页面"+res.data.result.list);
//                   appsearch.businessList = res.data.result.list;    
//                 
//              });
//      },
          /*computed: {
			      searchData: function() {
			      	 	console.log("开始查询"+this.searchModel);
					      var searchModel = this.searchModel;
					 			console.log("开始查询1"+this.searchModel);
					      if (searchModel) {
					        return this.businessList.filter(function(business) {
					          return Object.keys(business).some(function(key) {
					            return String(business[key]).toLowerCase().indexOf(searchModel) > -1
					          })
					        })
					        
					        return this.businessList;
					      }
					      else
					      {
					      	return "";
					      }
									      
					    }
	  		},*/
        methods:{
					detail:function(index){       
						appsearch.business = this.businessList[index];
						appsearch.id = appsearch.business.id;                  
						window.location.href='business_detail.html?id='+appsearch.id;      
             
    		} },
    	   computed: {
    	     searchData:  function() {
			      	 	console.log("开始查询"+this.searchModel);
					      var searchModel = this.searchModel;
					 			console.log("开始查询1"+this.searchModel);
					      if (searchModel) {
					        var url = "http://59.110.165.13:7500/business/findAllBusiness";
                  axios.post(url,{idOrName:searchModel}).then(function(res) {
                	 console.log("进入投票排行页面"+res.data.result.list);
                     appPaihangbang.businessList = res.data.result.list;
                     appPaihangbang.sumVote = res.data.result.sumVote;
                     appPaihangbang.businessCount = res.data.result.businessCount;
                     console.log("查询返回的结果1"+appPaihangbang.businessList);
                });					        
					    
					         
					        return appPaihangbang.businessList;
					      }
					      else
					      {
					      	return "";
					      }
									      
					    }
    	   } 



   })		
		
		
		
					